package com.easylinkin.linkappapi.quality.controller.screen;

import com.easylinkin.linkappapi.quality.dto.QualityScreenDTO;
import com.easylinkin.linkappapi.quality.service.QualityQuestionInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

/**
 * @author: kan yuanfeng
 * @Date: 2020/11/04 11:42
 * @Description: 质量大屏管理
 */
@RestController
@RequestMapping("qualityScreen")
@Api(tags = "质量大屏管理")
public class QualityScreenController {
  
  @Autowired
  private QualityQuestionInfoService qualityQuestionInfoService;

  /**
   * @Description: 质量问题分类统计
   * @author kan yuanfeng
   * @date 2020/11/04 11:42
   */
  @PostMapping("problemType")
  @ApiOperation("质量问题分类统计")
  public RestMessage getByProblemType(@RequestBody QualityScreenDTO qualityScreenDTO){
    List<QualityScreenDTO> list =  qualityQuestionInfoService.getByProblemType(qualityScreenDTO);
    return RestBuilders.successBuilder().data(list).build();
  }

  /**
   * @Description: 最新问题
   * @author kan yuanfeng
   * @date 2020/11/04 11:42
   */
//  @PostMapping("problemType")
//  @ApiOperation("质量问题分类统计")
//  public RestMessage getByProblemType(@RequestBody QualityScreenDTO qualityScreenDTO){
//    List<QualityScreenDTO> list =  qualityQuestionInfoService.getByProblemType(qualityScreenDTO);
//    return RestBuilders.successBuilder().data(list).build();
//  }

  /**
   * @Description: 整改率统计
   * @author kan yuanfeng
   * @date 2020/11/04 11:42
   */
  @PostMapping("dealRecord")
  @ApiOperation("整改率统计")
  public RestMessage dealRecord(){
    List<String> list =  qualityQuestionInfoService.dealRecord(null);
    return RestBuilders.successBuilder().data(list).build();
  }

  /**
   * @Description: 统计概览
   * @author kan yuanfeng
   * @date 2020/11/04 11:42
   */
  @PostMapping("overview")
  @ApiOperation("统计概览")
  public RestMessage overview(){
    List<Integer> list = qualityQuestionInfoService.overview();
    return RestBuilders.successBuilder().data(list).build();
  }

  /**
   * @Description: 分包单位统计
   * @author kan yuanfeng
   * @date 2020/11/04 11:42
   */
  @PostMapping("subOrg")
  @ApiOperation("分包单位统计")
  public RestMessage getBySubOrg(){
    List<QualityScreenDTO> list = qualityQuestionInfoService.getBySubOrg();
    return RestBuilders.successBuilder().data(list).build();
  }

  /**
   * @Description: 查询一个月内的数据
   * @author kan yuanfeng
   * @date 2020/11/04 11:42
   */
  @PostMapping("month")
  @ApiOperation("分包单位统计")
  public RestMessage getByMonth(){
    List<QualityScreenDTO> list = qualityQuestionInfoService.getByMonth();
    return RestBuilders.successBuilder().data(list).build();
  }

}

